import { PhysicsNodeLogic } from "./physicsNodeLogic";

const { ccclass, property } = cc._decorator;
let talefun = (<any>cc).talefun;

@ccclass
export default class GameViewLogic extends cc.Component {

    @property(cc.Prefab)
    private physicsNodePrefab: cc.Prefab = null;

    private physicsNode: cc.Node = null;

    onLoad() {
        cc.director.getPhysicsManager().enabled = true;
        cc.director.getPhysicsManager().debugDrawFlags = 0 | 0 | 0 | 1 | 0;
        cc.director.getPhysicsManager().gravity = cc.v2(0, -300);

        this.node.on(cc.Node.EventType.TOUCH_START, this.touchStart, this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchCancel, this);

        let physicsNode = cc.instantiate(this.physicsNodePrefab);
        this.node.addChild(physicsNode);
    }


    touchStart(event: cc.Event.EventTouch) {
        cc.log("GameViewLogic touchStart");
        let physicsNode = cc.instantiate(this.physicsNodePrefab);
        this.node.addChild(physicsNode);
    }

    touchMove(event: cc.Event.EventTouch) {
      
    }

    touchEnd(event: cc.Event.EventTouch) {
    
    }

    touchCancel(event: cc.Event.EventTouch) {
    }
}
